package com.hyt.it.ogt.ks.feign.es;

import java.util.List;

import com.hyt.it.ogt.ks.es.CandidateOperationTrackLogDTO;
import org.springframework.stereotype.Component;

import com.hyt.it.ogt.ks.feign.model.es.EsApplyCheckRecord;
import com.hyt.it.ogt.ks.feign.model.es.EsExceptionManageRecord;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * es服务调用失败处理类
 *
 * @author zhoumiao
 * @since 2022/11/24 13:44
 **/
@Slf4j
@Component
public class EsClientFallbackFactory implements FallbackFactory<EsClient> {
    @Override
    public EsClient create(Throwable throwable) {
        return new EsClient() {

            @Override
            public void saveOrUpdate(EsExceptionManageRecord exceptionManageRecord) {
                log.error("保存或者更新异常操作到es 参数：{} 错误：", exceptionManageRecord, throwable);
            }

            @Override
            public void delete(List<String> ids) {
                log.error("通过异常操作表id删除es中异常操作 参数：{} 错误：", ids, throwable);
            }

            @Override
            public void saveOrUpdate(EsApplyCheckRecord esApplyCheckRecord) {
                log.error("保存或者更新异常审核操作到es 参数：{} 错误：", esApplyCheckRecord, throwable);
            }
            @Override
            public void deleteApplyCheck(List<String> ids) {
                log.error("通过异常操作操作表id删除es中异常审核 参数：{} 错误：", ids, throwable);
            }

            @Override
            public void deleteLogOtherByBeforeDays(Integer beforeDays) {
                log.error("更新指定考场指定考生异常数据 参数：{} 错误：", beforeDays, throwable);
            }

            @Override
            public void deleteApplyCheckByBeforeDays(Integer beforeDays) {
                log.error("指定参数需要删除多少天之前的异常数据 参数：{} 错误：", beforeDays, throwable);
            }

            @Override
            public void saveCandidateOperationTrackLog(List<CandidateOperationTrackLogDTO> candidateOperationTrackLogList) {
                log.error("考生行为轨迹记录异常数据 参数：{} 错误：", candidateOperationTrackLogList, throwable);
            }

            @Override
            public void asyncSaveCandidateOperationTrackLog(List<CandidateOperationTrackLogDTO> candidateOperationTrackLogList) {
                log.error("考生行为轨迹异步记录异常数据 参数：{} 错误：", candidateOperationTrackLogList, throwable);
            }

            @Override
            public void deleteCandidateOperationTrackLogByExamId(String examId) {
                log.error("根据考试ID删除考生轨迹异常 参数：{} 错误：", examId, throwable);
            }

            @Override
            public void deleteCandidateOperationTrackLogAll() {
                log.error("删除考生轨迹异常错误：", throwable);
            }
        };
    }
}
